package symbolrt.translation.parser.base;

import java.util.LinkedList;
import java.util.List;
/**
 * <code>AbstractTIOSTS</code> Class. <br>
 * 
 * Intermediate representation of a Expression
 * 
 * @author Jeanderson Barros Candido ( <a
 *         href="mailto:jeandersonbc@gmail.com">jeandersonbc@gmail.com</a> )
 * 
 * @version 1.0 <br>
 *          (C) Copyright 2012 SYMBOL-RT Translator.
 */
public class AbstractExpression {

	List<Element> expression;
	private boolean isClockAssignment;

	public AbstractExpression(boolean isClockAssignment) {
		this.expression = new LinkedList<Element>();
		this.isClockAssignment = isClockAssignment;
	}

	public AbstractExpression() {
		this.expression = new LinkedList<Element>();
		this.isClockAssignment = false;
	}

	public void addElement(Element e) {
		if (e != null) {
			expression.add(e);
		}
	}

	@Override
	public String toString() {
		String str = "";
		for (Element e : expression) {
			if (e.getToken().image.equals("(")) {
				str += e.getToken().image;
			} else if (e.getToken().image.equals(")")) {
				str = str.trim() + e.getToken().image + " ";
			} else {
				str += e.getToken().image + " ";
			}
		}
		return str.trim();
	}

	public boolean isClockAssignment() {
		return this.isClockAssignment;
	}

}
